1. /* srmeffig.cpp by K.Tsuru */
  2. // function ID = 008
  3. /**************************************
  4. RealSize class
  5. 1.destructor
  6. 2.Set the numbers of effective figures.
  7. ***************************************/
  8. #ifndef SN_H
  9. #include "sn.h"
  10. #endif
  11. RealSize::~RealSize(){
  12. if(size[0]) Restore(); // restore effective figures
  13. }
  14. uint RealSize::SetEffFig(uint fig, int proper){
  15. if(proper & PREF_SPEED) preferSpeed = true;
  16. if(!fig){ //It restores to the previous values.
  17. if(size[0] == 0) SetError(SET_EFF_FIG, "No data", 8);
  18. Restore();
  19. return effFigures;
  20. }
  21. //It saves present figures and size.
  22. if(size[0] != 0) SetError(SET_EFF_FIG, "Save data twice", 8);
  23. Save();
  24. if(effFigures == fig) return effFigures;
  25. //necessary size including hidden figures and figure[0]
  26. uint oldsz = effFigures + hidden + 1u, hdn;
  27. int decr_fig = 0;
  28. //When the number of hidden figures increases by adding hidden figures
  29. //it decreases by "decr_fig" figures.
  30. hidden = HiddenSize(fig);
  31. hdn = HiddenSize(fig+hidden+1u);
  32. if( (hdn > hidden) && !(proper & TEMP_EXTEND)){
  33. fig -= hdn; decr_fig = (int)hdn;
  34. }
  35. uint sz = ceilpow2(fig);
  36. while(decr_fig && (fig + hidden + 1u < sz)){
  37. //It restores the decreased figures as much as possible.
  38. fig++; decr_fig--;
  39. }
  40. if( sz <= minArraySize ){
  41. sz = 2u*minArraySize;
  42. effFigures = sz - hidden -1u;
  43. } else if( sz > MaxArraySize() ){
  44. if(!(proper & TEMP_EXTEND)) SetError(SET_EFF_FIG, "Effective figures is too large.", -8);
  45. //Because there is functions which temporally increases the effective figures
  46. //it decreases the effective figures a little.
  47. sz = MaxArraySize() - 8u;
  48. effFigures = sz - hidden -1u;
  49. proper = 0;
  50. } else effFigures = fig;
  51. /****************************************************************
  52. It provides a proper value of effFigures which is efficient for
  53. FFT multiplication and memory.It is desirable to adopt the value
  54. of CurrentMaxSize()(=effFigures+hidden+1u) as power of two because
  55. the upper part is taken one figure larger in DDMult().
  56. example :
  57. sz = CurrentMaxSize() = 128, effFigures = 125, hidden = 2.
  58. Excluding the first zero (128-1)/2+1=64(= 2^6) figures are passed
  59. to LLMult().
  60. *****************************************************************/
  61. sz = effFigures + hidden +1u;
  62. if(proper & PROPER){
  63. sz = ceilpow2(sz);
  64. hidden = HiddenSize(sz- hidden -1u);
  65. effFigures = sz - hidden -1u;
  66. }
  67. /*
  68. In the fixed point mode(reduceMaxSize == DISABLE, using the doubling effective
  69. figures method etc) it changes the value of maxSize when the present size is
  70. greater than the previous one only.
  71. */
  72. if( (reduceMaxSize == ENABLE) || (sz > oldsz) ) SetMaxSize();
  73. return effFigures;
  74. }

smrsteff.cpp : last modifiled at 2017/03/06 16:01:25(2,716 bytes)
created at 2016/04/11 11:36:47
The creation time of this html file is 2017/10/27 10:59:17 (Fri Oct 27 10:59:17 2017).